import 'package:flutter/material.dart';
import 'package:flutterapp/Base/DemoUI/DemoPageGetRouteArgs.dart';
import 'package:flutterapp/Base/DemoUI/DemoPageMain.dart';
import 'package:flutterapp/Base/DemoUI/DemoPageRefreshLoad.dart';
import 'package:flutterapp/Base/DemoUI/DemoPageTab.dart';
import 'package:flutterapp/Base/PageSocketTest.dart';
import 'package:flutterapp/Pages/PageLogin.dart';
import 'package:flutterapp/Pages/PageMain.dart';

import '../PageTest.dart';

//全局导航监听 可获取navigator
class MyNavigatorObserver extends NavigatorObserver {
  static MyNavigatorObserver _instance = MyNavigatorObserver._();

  MyNavigatorObserver._();

  factory MyNavigatorObserver.getInstance() {
    if (_instance == null) {
      _instance = MyNavigatorObserver._();
    }
    return _instance;
  }
}

//错误路由页
class PageErr extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
          child: Center(
        child: Container(
          child: Text("no such route."),
        ),
      )),
    );
  }
}

//路由表
Map<String, WidgetBuilder> RouterMap = {
  "/": (context) => PageLogin(),
  // "/": (context) => PageTest(),
  DemoPageMain.ROUTER_NAME: (context) => DemoPageMain(),
  DemoPageTab.ROUTER_NAME: (context) => DemoPageTab(),
  DemoPageRefreshLoad.ROUTER_NAME: (context) => DemoPageRefreshLoad(),
  DemoPageGetRouteArgs.ROUTER_NAME: (context) => DemoPageGetRouteArgs(),
  PageSocketTest.ROUTER_NAME: (context) => PageSocketTest(),
  PageLogin.ROUTER_NAME: (context) => PageLogin(),
  PageMain.ROUTER_NAME:(context) => PageMain(),
};
